﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Csla.Data;

namespace Northwind.DataAccess.Linq
{
    public class ProductDal : IProductDal
    {
        #region IProductDal Members

        public List<ProductDto> Fetch()
        {
            using (var ctx = ContextManager<NorthwindDataContext>.GetManager("Northwind")) 
            { 
                // ctx.Context is the LINQ to SQL context object 
                var result = from p in ctx.DataContext.Products
                             select new ProductDto
                             {
                                ProductId = p.ProductID,
                                ProductName = p.ProductName,
                                SupplierId = p.SupplierID ,
                                CategoryId = p.CategoryID	,
                                QuantityPerUnit = p.QuantityPerUnit,
                                UnitPrice = p.UnitPrice,
                                UnitsInStock = p.UnitsInStock,
                                UnitsOnOrder = p.UnitsOnOrder	,
                                ReorderLevel = p.ReorderLevel,
                                Discontinued = p.Discontinued
                             };
                return result.ToList();
            }
        }

        public List<ProductDto> Fetch(string nameFilter)
        {
            throw new NotImplementedException();
        }

        public ProductDto Fetch(int id)
        {
            throw new NotImplementedException();
        }

        public bool Exists(int id)
        {
            throw new NotImplementedException();
        }

        public void Insert(ProductDto item)
        {
            throw new NotImplementedException();
        }

        public void Update(ProductDto item)
        {
            throw new NotImplementedException();
        }

        public void Delete(int id)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
